﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Whir.Common.WebHelper;
using Whir.Common;

public partial class Whir_System_Module_Job_JobRequestInfo : System.Web.UI.Page
{
    protected int TypeID;
    protected int ItemID;
    protected string url;
    protected void Page_Load(object sender, EventArgs e)
    {
        TypeID = NetRequest.GetQueryInt("TypeID");
        ItemID = NetRequest.GetQueryInt("ItemID");
        url = Server.HtmlEncode(NetRequest.GetUrl());
        if (!IsPostBack)
        {
            BindData();
        }
    }

    private void BindData()
    {
        Whir.BLL.Whir_JobRequest bll = new Whir.BLL.Whir_JobRequest();
        Whir.Model.Whir_JobRequest model = bll.GetModel(ItemID);
        if (model == null)
            return;

        #region

        this.txtJobID.Text = Whir.SQLServerDAL.DbHelperSQL.GetSingle("select JobName from whir_U_job where Whir_U_Job_PID = " + model.JobID).ToString();
        this.lbCreateDate.Text = "【" + model.CreateDate.ToString("yyyy-MM-dd") + "】";

        if (string.IsNullOrEmpty(model.Bumen))
        {
            this.HyperLink1.NavigateUrl = "#";
            this.HyperLink1.Text = "暂无图片";
            this.HyperLink1.Enabled = false;
        }
        else
        {
            this.HyperLink1.NavigateUrl = "http://www.dnssh.com.cn" + Settings.GetString("PicServer") + model.Bumen;
        }


        this.txtTaxIncluded.Text = model.TaxIncluded;
        this.txtTaxExcluded.Text = model.TaxExcluded;
        this.txtName.Text = model.Name;
        rbltxtMaritalStatus.Text = model.MaritalStatus ? "已婚" : "未婚";
        rblSex.Text = model.Sex ? "男" : "女";
        this.txtNativePlace.Text = model.NativePlace;
        this.txtDateOfBirth.Text = model.DateOfBirth.ToString("D");
        this.txtIDCardNo.Text = model.IDCardNo;
        this.txtContactWay.Text = model.ContactWay;
        this.txtHomePhone.Text = model.HomePhone;
        this.txtMobile.Text = model.Mobile;
        this.txtResidentialAddress.Text = model.ResidentialAddress;
        this.txtEyesightLeft.Text = model.EyesightLeft;
        this.txtEyesightRight.Text = model.EyesightRight;
        this.txtHeight.Text = model.EyeHeight;
        this.txtWeight.Text = model.Weight;
        this.txtHealth.Text = model.Health;
        this.txtAnyAilment.Text = model.AnyAilment;
        this.txtDwellingAddress.Text = model.DwellingAddress;

        this.chkTransfer.Text = model.TrafficInfo;

        this.rblTransfer.Text = model.Transfer ? "原意" : "不原意";

        if (model.FatherDesc.Split('|').Length > 1)
        {
            this.txtFatherDesc1.Text = model.FatherDesc.Split('|')[0];
            this.txtFatherDesc2.Text = model.FatherDesc.Split('|')[1];
            this.txtFatherDesc3.Text = model.FatherDesc.Split('|')[2];
        }

        if (model.MotherDesc.Split('|').Length > 1)
        {
            this.txtMotherDesc1.Text = model.MotherDesc.Split('|')[0];
            this.txtMotherDesc2.Text = model.MotherDesc.Split('|')[1];
            this.txtMotherDesc3.Text = model.MotherDesc.Split('|')[2];
        }

        if (model.SpouseDesc.Split('|').Length > 1)
        {
            this.txtSpouseDesc1.Text = model.SpouseDesc.Split('|')[0];
            this.txtSpouseDesc2.Text = model.SpouseDesc.Split('|')[1];
            this.txtSpouseDesc3.Text = model.SpouseDesc.Split('|')[2];
        }
        this.txtBrothersNum.Text = model.BrothersNum.ToString();
        this.txtSistersNum.Text = model.SistersNum.ToString();
        this.txtChildrenNum.Text = model.ChildrenNum.ToString();

        if (model.EmergencyCommunicant.Split('|').Length > 1)
        {
            this.txtEmergencyCommunicant1.Text = model.EmergencyCommunicant.Split('|')[0];
            this.txtEmergencyCommunicant2.Text = model.EmergencyCommunicant.Split('|')[1];
            this.txtEmergencyCommunicant3.Text = model.EmergencyCommunicant.Split('|')[2];
            this.txtEmergencyCommunicant4.Text = model.EmergencyCommunicant.Split('|')[3];
        }

        if (model.EduSecondarvl.Split('|').Length > 1)
        {
            this.txtEduSecondarvl1.Text = model.EduSecondarvl.Split('|')[0];
            this.txtEduSecondarvl2.Text = model.EduSecondarvl.Split('|')[1];
            this.txtEduSecondarvl3.Text = model.EduSecondarvl.Split('|')[2];
            this.txtEduSecondarvl4.Text = model.EduSecondarvl.Split('|')[3];
            this.txtEduSecondarvl5.Text = model.EduSecondarvl.Split('|')[4];
            this.txtEduSecondarvl6.Text = model.EduSecondarvl.Split('|')[5];
            this.txtEduSecondarvl7.Text = model.EduSecondarvl.Split('|')[6];
            this.txtEduSecondarvl8.Text = model.EduSecondarvl.Split('|')[7];
        }

        if (model.EduBachelor.Split('|').Length > 1)
        {
            this.txtEduBachelor1.Text = model.EduBachelor.Split('|')[0];
            this.txtEduBachelor2.Text = model.EduBachelor.Split('|')[1];
            this.txtEduBachelor3.Text = model.EduBachelor.Split('|')[2];
            this.txtEduBachelor4.Text = model.EduBachelor.Split('|')[3];
            this.txtEduBachelor5.Text = model.EduBachelor.Split('|')[4];
            this.txtEduBachelor6.Text = model.EduBachelor.Split('|')[5];
            this.txtEduBachelor7.Text = model.EduBachelor.Split('|')[6];
            this.txtEduBachelor8.Text = model.EduBachelor.Split('|')[7];
        }

        if (model.EduDoctor.Split('|').Length > 1)
        {
            this.txtEduDoctor1.Text = model.EduDoctor.Split('|')[0];
            this.txtEduDoctor2.Text = model.EduDoctor.Split('|')[1];
            this.txtEduDoctor3.Text = model.EduDoctor.Split('|')[2];
            this.txtEduDoctor4.Text = model.EduDoctor.Split('|')[3];
            this.txtEduDoctor5.Text = model.EduDoctor.Split('|')[4];
            this.txtEduDoctor6.Text = model.EduDoctor.Split('|')[5];
            this.txtEduDoctor7.Text = model.EduDoctor.Split('|')[6];
            this.txtEduDoctor8.Text = model.EduDoctor.Split('|')[7];
        }

        if (model.JobExerience1.Split('|').Length > 1)
        {
            txtJobExerience11.Text = model.JobExerience1.Split('|')[0];
            txtJobExerience12.Text = model.JobExerience1.Split('|')[1];
            txtJobExerience13.Text = model.JobExerience1.Split('|')[2];
            txtJobExerience14.Text = model.JobExerience1.Split('|')[3];
            txtJobExerience15.Text = model.JobExerience1.Split('|')[4];
            txtJobExerience16.Text = model.JobExerience1.Split('|')[5];
            txtJobExerience17.Text = model.JobExerience1.Split('|')[6];
            txtJobExerience18.Text = model.JobExerience1.Split('|')[7];
        }

        if (model.JobExerience2.Split('|').Length > 1)
        {
            txtJobExerience21.Text = model.JobExerience2.Split('|')[0];
            txtJobExerience22.Text = model.JobExerience2.Split('|')[1];
            txtJobExerience23.Text = model.JobExerience2.Split('|')[2];
            txtJobExerience24.Text = model.JobExerience2.Split('|')[3];
            txtJobExerience25.Text = model.JobExerience2.Split('|')[4];
            txtJobExerience26.Text = model.JobExerience2.Split('|')[5];
            txtJobExerience27.Text = model.JobExerience2.Split('|')[6];
            txtJobExerience28.Text = model.JobExerience2.Split('|')[7];
        }

        if (model.JobExerience3.Split('|').Length > 1)
        {
            txtJobExerience11.Text = model.JobExerience3.Split('|')[0];
            txtJobExerience12.Text = model.JobExerience3.Split('|')[1];
            txtJobExerience13.Text = model.JobExerience3.Split('|')[2];
            txtJobExerience14.Text = model.JobExerience3.Split('|')[3];
            txtJobExerience15.Text = model.JobExerience3.Split('|')[4];
            txtJobExerience16.Text = model.JobExerience3.Split('|')[5];
            txtJobExerience17.Text = model.JobExerience3.Split('|')[6];
            txtJobExerience18.Text = model.JobExerience3.Split('|')[7];
        }

        if (model.JobExerience4.Split('|').Length > 1)
        {
            txtJobExerience41.Text = model.JobExerience4.Split('|')[0];
            txtJobExerience42.Text = model.JobExerience4.Split('|')[1];
            txtJobExerience43.Text = model.JobExerience4.Split('|')[2];
            txtJobExerience44.Text = model.JobExerience4.Split('|')[3];
            txtJobExerience45.Text = model.JobExerience4.Split('|')[4];
            txtJobExerience46.Text = model.JobExerience4.Split('|')[5];
            txtJobExerience47.Text = model.JobExerience4.Split('|')[6];
            txtJobExerience48.Text = model.JobExerience4.Split('|')[7];
        }

        if (model.JobExerience5.Split('|').Length > 1)
        {
            txtJobExerience51.Text = model.JobExerience5.Split('|')[0];
            txtJobExerience52.Text = model.JobExerience5.Split('|')[1];
            txtJobExerience53.Text = model.JobExerience5.Split('|')[2];
            txtJobExerience54.Text = model.JobExerience5.Split('|')[3];
            txtJobExerience55.Text = model.JobExerience5.Split('|')[4];
            txtJobExerience56.Text = model.JobExerience5.Split('|')[5];
            txtJobExerience57.Text = model.JobExerience5.Split('|')[6];
            txtJobExerience58.Text = model.JobExerience5.Split('|')[7];
        }

        string Language1 = this.txtLanguage11.Text + "|" + this.txtLanguage12.Text + "|" + this.txtLanguage13.Text + "|" +
            this.txtLanguage14.Text + "|" + this.txtLanguage15.Text;
        string Language2 = this.txtLanguage21.Text + "|" + this.txtLanguage22.Text + "|" + this.txtLanguage23.Text + "|" +
            this.txtLanguage24.Text + "|" + this.txtLanguage25.Text;

        if (model.Language1.Split('|').Length > 1)
        {
            this.txtLanguage11.Text = model.Language1.Split('|')[0];
            this.txtLanguage12.Text = model.Language1.Split('|')[1];
            this.txtLanguage13.Text = model.Language1.Split('|')[2];
            this.txtLanguage14.Text = model.Language1.Split('|')[3];
            this.txtLanguage15.Text = model.Language1.Split('|')[4];
        }

        if (model.Language2.Split('|').Length > 1)
        {
            this.txtLanguage21.Text = model.Language2.Split('|')[0];
            this.txtLanguage22.Text = model.Language2.Split('|')[1];
            this.txtLanguage23.Text = model.Language2.Split('|')[2];
            this.txtLanguage24.Text = model.Language2.Split('|')[3];
            this.txtLanguage25.Text = model.Language2.Split('|')[4];
        }

        this.txtCertificate1.Text = model.Certificate1;
        this.txtCertificate2.Text = model.Certificate2;
        this.txtHobbies.Text = model.Hobbies;
        #endregion
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        Page.EnableViewState = false;
        string fileName = "";
        fileName = this.txtName.Text.Trim() + "的简历";
        HttpContext.Current.Response.Clear();
        HttpContext.Current.Response.AppendHeader("Content-Disposition", "attachment;filename=" + HttpUtility.UrlEncode(fileName, System.Text.Encoding.UTF8) + ".doc");
        HttpContext.Current.Response.Charset = "UTF-8";
        HttpContext.Current.Response.ContentEncoding = System.Text.Encoding.UTF8;
        HttpContext.Current.Response.ContentType = "application/ms-word";
        System.IO.StringWriter tw = new System.IO.StringWriter();
        System.Web.UI.HtmlTextWriter hw = new System.Web.UI.HtmlTextWriter(tw);
        this.Button1.Visible = false;
        this.Page.RenderControl(hw);
        HttpContext.Current.Response.Write(tw.ToString());
        HttpContext.Current.Response.End();
    }
}